-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add codegen ios.componentProvider
#2572
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Dec 10, 2024
j-piasecki
pushed a commit
to software-mansion/react-native-gesture-handler
that referenced
this pull request
Dec 13, 2024
## Description * 54710a6 - Added `sourceSets` to the package due to changes in ViewManager function signatures, which are no longer nullable * a20adca - Updated to reflect changes in facebook/react-native#47551, `findHostInstance_DEPRECATED` is now a property of the `default` object instead of being a named export. Modified implementation reads from default and fall back to named export as needed * ac7e786 - Similar change to the software-mansion/react-native-svg#2572 that uses new API to create an association map between JS components and their native implementations, avoiding `codegen` crawling through the entire filesystem for `.mm` files. ## Test plan App with React Native 0.77 (like #3277) should compile and work as expected.
kkafar
pushed a commit
to software-mansion/react-native-screens
that referenced
this pull request
Dec 16, 2024
## Description Add a newly introduced field `ios.componentProvider` to the `codegen` configuration to create an association map between JS components and their native implementations. See more information here: software-mansion/react-native-svg#2572 ## Changes - added `codegenConfig.ios.componentProvider` field to package.json ### Before ```objc Class<RCTComponentViewProtocol> RCTThirdPartyFabricComponentsProvider(const char *name) { static std::unordered_map<std::string, Class (*)(void)> sFabricComponentsClassMap = { // ... {"RNSFullWindowOverlay", RNSFullWindowOverlayCls}, // 3 {"RNSModalScreen", RNSModalScreenCls}, // 3 {"RNSScreenContainer", RNSScreenContainerCls}, // 3 {"RNSScreenContentWrapper", RNSScreenContentWrapperCls}, // 3 {"RNSScreenFooter", RNSScreenFooterCls}, // 3 {"RNSScreen", RNSScreenCls}, // 3 {"RNSScreenNavigationContainer", RNSScreenNavigationContainerCls}, // 3 {"RNSScreenStackHeaderConfig", RNSScreenStackHeaderConfigCls}, // 3 {"RNSScreenStackHeaderSubview", RNSScreenStackHeaderSubviewCls}, // 3 {"RNSScreenStack", RNSScreenStackCls}, // 3 {"RNSSearchBar", RNSSearchBarCls}, // 3 // ... ``` ### After ```objc @implementation RCTThirdPartyComponentsProvider + (NSDictionary<NSString *, Class<RCTComponentViewProtocol>> *)thirdPartyFabricComponents { return @{ @"RNSFullWindowOverlay": NSClassFromString(@"RNSFullWindowOverlay"), // react-native-screens @"RNSModalScreen": NSClassFromString(@"RNSModalScreen"), // react-native-screens @"RNSScreenContainer": NSClassFromString(@"RNSScreenContainer"), // react-native-screens @"RNSScreenContentWrapper": NSClassFromString(@"RNSScreenContentWrapper"), // react-native-screens @"RNSScreenFooter": NSClassFromString(@"RNSScreenFooter"), // react-native-screens @"RNSScreen": NSClassFromString(@"RNSScreen"), // react-native-screens @"RNSScreenNavigationContainer": NSClassFromString(@"RNSScreenNavigationContainer"), // react-native-screens @"RNSScreenStackHeaderConfig": NSClassFromString(@"RNSScreenStackHeaderConfig"), // react-native-screens @"RNSScreenStackHeaderSubview": NSClassFromString(@"RNSScreenStackHeaderSubview"), // react-native-screens @"RNSScreenStack": NSClassFromString(@"RNSScreenStack"), // react-native-screens @"RNSSearchBar": NSClassFromString(@"RNSSearchBar"), // react-native-screens }; } ``` ## Test code and steps to reproduce Run `pod install` in React Native 0.77 app and see `RCTThirdPartyFabricComponentsProvider` to check the content
kligarski
pushed a commit
to software-mansion/react-native-screens
that referenced
this pull request
Feb 25, 2025
## Description Add a newly introduced field `ios.componentProvider` to the `codegen` configuration to create an association map between JS components and their native implementations. See more information here: software-mansion/react-native-svg#2572 ## Changes - added `codegenConfig.ios.componentProvider` field to package.json ### Before ```objc Class<RCTComponentViewProtocol> RCTThirdPartyFabricComponentsProvider(const char *name) { static std::unordered_map<std::string, Class (*)(void)> sFabricComponentsClassMap = { // ... {"RNSFullWindowOverlay", RNSFullWindowOverlayCls}, // 3 {"RNSModalScreen", RNSModalScreenCls}, // 3 {"RNSScreenContainer", RNSScreenContainerCls}, // 3 {"RNSScreenContentWrapper", RNSScreenContentWrapperCls}, // 3 {"RNSScreenFooter", RNSScreenFooterCls}, // 3 {"RNSScreen", RNSScreenCls}, // 3 {"RNSScreenNavigationContainer", RNSScreenNavigationContainerCls}, // 3 {"RNSScreenStackHeaderConfig", RNSScreenStackHeaderConfigCls}, // 3 {"RNSScreenStackHeaderSubview", RNSScreenStackHeaderSubviewCls}, // 3 {"RNSScreenStack", RNSScreenStackCls}, // 3 {"RNSSearchBar", RNSSearchBarCls}, // 3 // ... ``` ### After ```objc @implementation RCTThirdPartyComponentsProvider + (NSDictionary<NSString *, Class<RCTComponentViewProtocol>> *)thirdPartyFabricComponents { return @{ @"RNSFullWindowOverlay": NSClassFromString(@"RNSFullWindowOverlay"), // react-native-screens @"RNSModalScreen": NSClassFromString(@"RNSModalScreen"), // react-native-screens @"RNSScreenContainer": NSClassFromString(@"RNSScreenContainer"), // react-native-screens @"RNSScreenContentWrapper": NSClassFromString(@"RNSScreenContentWrapper"), // react-native-screens @"RNSScreenFooter": NSClassFromString(@"RNSScreenFooter"), // react-native-screens @"RNSScreen": NSClassFromString(@"RNSScreen"), // react-native-screens @"RNSScreenNavigationContainer": NSClassFromString(@"RNSScreenNavigationContainer"), // react-native-screens @"RNSScreenStackHeaderConfig": NSClassFromString(@"RNSScreenStackHeaderConfig"), // react-native-screens @"RNSScreenStackHeaderSubview": NSClassFromString(@"RNSScreenStackHeaderSubview"), // react-native-screens @"RNSScreenStack": NSClassFromString(@"RNSScreenStack"), // react-native-screens @"RNSSearchBar": NSClassFromString(@"RNSSearchBar"), // react-native-screens }; } ``` ## Test code and steps to reproduce Run `pod install` in React Native 0.77 app and see `RCTThirdPartyFabricComponentsProvider` to check the content
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Add a newly introduced field
ios.componentProvider
to thecodegen
configuration to create an association map between JS components and their native implementations.When this field is defined, it is used and codegen don't crawl the file system looking for the mapping. You can find the documentation for it here: https://github.com/facebook/react-native-website/pull/4388/files#diff-7fbb6ff2e58f8bd50d2763e551c63e1816adb6d593f40d489785b575b0e82718R76
Test Plan
Running
pod install
in thetests-example
will currently hang and eventually crash, as it attempts to crawl through the entire repository.